	var FRIENDS = {
		init	: function(){
			var self = this;	
			self.UI.init();
		}
	}

	FRIENDS.TEMPLATE = {
		friends_item	: [
		 '<div class="friends_item">' +
			'<div class="friends_img" style="background-image:url(\'',/*1:img*/,'\')" width="150"></div>' +
			'<div class="friends_detail">' +
				'<p>',/*3:name*/,'</p>' +
				'<ul>' +
					'<li><span>Level</span>:',/*5:level*/,'</li>' +
					'<li><span>Emotion</span> :',/*7:emotion*/,'</li>' +
					'<li><span>Activity</span> :',/*9:activity*/,'</li>' +
					'<li><span>History</span> :',/*11:history*/,'</li>' +
					'<li><span>Scrap</span> :',/*13:scrap*/,'</li>' +
					'<li><span>Comments</span> :',/*15:comments*/,'</li>' +
					'<li><span>Last Login</span> :',/*17:last login*/,'</li>' +
				'</ul>' +
			'</div>' +
		  '</div>' 
		]
	}

	FRIENDS.UI = {
		init	: function(){
			var self = this;
			self.load();
		},
		emotion_flag	 : ['ㅡ_ㅡ','O_O','^__^','^O^'],
		level	: [
			'',
			'Ggugi',
			'Soul mate',
			'Friend',
			'Good man',
			'Stranger',
			'Amoeba'
		],

		make	: function(){
			var self=this;
			
			for(var i=0;i<self.friends.length;i++){
				FRIENDS.TEMPLATE.friends_item[1] = self.friends[i]['m_profile_img']; 
				FRIENDS.TEMPLATE.friends_item[3] = self.friends[i]['m_name']; 
				FRIENDS.TEMPLATE.friends_item[5] = self.level[self.friends[i]['m_level']]; 
				FRIENDS.TEMPLATE.friends_item[7] = self.friends[i]['m_emotion_point']; 
				FRIENDS.TEMPLATE.friends_item[9] = self.friends[i]['m_total_point']; 
				FRIENDS.TEMPLATE.friends_item[11] = self.friends[i]['history']; 
				FRIENDS.TEMPLATE.friends_item[13] = self.friends[i]['scrap']; 
				FRIENDS.TEMPLATE.friends_item[15] = self.friends[i]['comments']; 
				var d = new Date(self.friends[i]['m_update_time']*1000);
				FRIENDS.TEMPLATE.friends_item[17] = d.getFullYear() +"-"+parseInt(d.getMonth()+1)+"-"+d.getDate(); 
				
				$("#friends_area").append(FRIENDS.TEMPLATE.friends_item.join(''));
			}	
			
		},
		load	: function(){
			var self = this; 
			var sendData = {
				"service"	: "api_get_friends"
			};

			$.ajax({
				url     : "/friends.php",
				type    : "post",
				async	: false,
				dataType: "json",
				data    : sendData,
				success : function(data){
					if(!data.RESULT_SET.flag){
						alert(data.RESULT_SET.msg);
						return false;
					}
					self.friends =data.RESPONSE;
					self.make();
				} 
			}); 
			
		
		}	
	}
